<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/dndTemplate.xhtml">


	
	<ui:define name="main">
	
		
			<table border="1" width="100%">
				<tr>
					<td colspan="2">
						<h:form >
						<p:growl id="messages" showDetail="true"/>  
						Name:<p:inputText value="#{adminCardsBean.searchCardName}" id="searchCardName" />
						Description:<p:inputText value="#{adminCardsBean.searchCardDesc}" id="searchCardDesc" /> 
						<p:commandButton value="Search" action="#{adminCardsBean.searchCard(adminCardsBean.cards)}" update=":cards"></p:commandButton>
						</h:form>
					</td>
				</tr>

				<tr>
					<td width="300" height="500" valign="top">
					<p:dataList
							value="#{adminCardsBean.cards}" var="card" id="cards"
							type="definition" paginator="true" rows="15">
							<h:form >
							<p:growl id="messages" showDetail="true"/>  


							<p:commandButton icon="ui-icon-search" update=":cardForm :allActions :actions"
								title="View Detail" action="#{myCardsBean.selectCard(card)}" />
							<p:graphicImage value="#{card.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40" height="50" />
					#{card.name}
							</h:form>

						</p:dataList></td>
					<td valign="top" >
						<table>
							<tr>
								<td valign="top">
								<h:form  id="cardForm" rendered="#{myCardsBean.selectedCard!=null}">
						
								Name:<p:inputText value="#{myCardsBean.selectedCard.name}" />
								<br />
								
								<p:graphicImage value="#{myCardsBean.selectedCard.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="240"
												height="300" />

										

										<br />
								Description:<p:inputText value="#{myCardsBean.selectedCard.description}" />
								<br />
								<p:commandButton  value="Save" action="#{adminCardsBean.searchCard(adminCardsBean.cards)}" update=":cards :cardForm" >
									<f:actionListener binding="#{myCardsBean.updateCard()}"/>
								</p:commandButton>
								<p:commandButton  value="Add"  action="#{adminCardsBean.searchCard(adminCardsBean.cards)}" update=":cards :cardForm">
									<f:actionListener binding="#{myCardsBean.createCard()}"/>
								</p:commandButton>
								<p:commandButton  value="Remove"  action="#{adminCardsBean.searchCard(adminCardsBean.cards)}" update=":cards :cardForm">
									<f:actionListener binding="#{myCardsBean.deleteCard()}"/>
								</p:commandButton>
								</h:form>
								<h:form enctype="multipart/form-data">
											<p:messages showDetail="true"/>  
											<p:fileUpload value="#{myCardsBean.uploadedFile}" mode="simple" />
											<p:commandButton value="submit" ajax="false"  action="#{adminCardsBean.searchCard(adminCardsBean.cards)}" update=":cards :cardForm" >
												<f:actionListener binding="#{myCardsBean.uploadCard(myCardsBean.selectedCard.id)}" />
											</p:commandButton>
											
								</h:form>
		
								
								</td>
								<td  height="600" valign="top">
								<h:form >
								<p:growl id="messages" showDetail="true"/>  
								Name:<p:inputText value="#{myCardsBean.searchActionName}"  /><br />
								Description:<p:inputText value="#{myCardsBean.searchActionDesc}"/> <br />
								<p:commandButton value="Search" action="#{myCardsBean.searchActionInCard(myCardsBean.actions,myCardsBean.cardActions)}" update=":actions"></p:commandButton>
								</h:form>
								<p:dataList id="actions"
										value="#{myCardsBean.cardActions}" var="card_action" type="definition" paginator="true" rows="10">
											<h:form >
											<p:growl id="messages" showDetail="true"/>  

											
											<p:graphicImage value="#{card_action.action.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40"
												height="50" />
											<h:outputText value="#{card_action.actionOrder}" />
											<h:outputText value="#{card_action.action.name}" />
											<p:graphicImage value="/images/x.bmp" width="30" height="30" />
											<h:outputText value="#{card_action.amount}"  />
											<p:commandButton icon="ui-icon-search" title="View" action="#{myCardsBean.selectAction(card_action)}"  update=":actionForm"/>
											<p:commandButton icon="ui-icon-carat-1-n" title="Up" action="#{myCardsBean.updateActionInCard(card_action.actionId, card_action.cardId, card_action.amount,card_action.actionOrder-1)}"  update=":actions"/>
											<p:commandButton icon="ui-icon-carat-1-s" title="Down" action="#{myCardsBean.updateActionInCard(card_action.actionId, card_action.cardId,card_action.amount,card_action.actionOrder+1)}"  update=":actions"/>

											</h:form>
										
									</p:dataList></td>

							</tr>


							<tr>
								<td valign="top">
								<h:form  id="actionForm">
								<p:growl id="messages" showDetail="true"/>  
								 
								Name:<h:outputText value="#{myCardsBean.selectedAction.name}" />
								<br />
								<p:graphicImage value="#{myCardsBean.selectedAction.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="240"
												height="300" />
								<br />
								Picture URL:<h:outputText value="#{myCardsBean.selectedAction.pictureURL}" />
								<br />
								Description:<h:outputText value="#{myCardsBean.selectedAction.description}" />
								<br />
							
								<p:commandButton  value="Save"  action="#{myCardsBean.updateActionInCard()}" update=":actions"/>
								<p:commandButton  value="Add"  action="#{myCardsBean.addActiontoCard()}" update=":actions"/>
								<p:commandButton  value="Remove"  action="#{myCardsBean.removeActionfromCard()}" update=":actions"/>
								<br />
								Amount:<p:inputText value="#{myCardsBean.selectedActionAmount}"/>
								</h:form>
								</td>
								<td>
									<h:form>
									<p:growl id="messages" showDetail="true" />  
									Name:<p:inputText value="#{myCardsBean.searchActionName}" />
									<br />
									Description:<p:inputText value="#{myCardsBean.searchActionDesc}" />
									<br />
									<p:commandButton value="Search" action="#{myCardsBean.searchAction(myCardsBean.allActions,null)}" update=":allActions"></p:commandButton>
									</h:form> 
									<p:dataList id="allActions" value="#{myCardsBean.allActions}" var="action" type="definition" paginator="true" rows="10">
									<h:form>
										<p:growl id="messages" showDetail="true" />

										<h:outputText value="#{action.name}" />
										<p:graphicImage value="#{action.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40" height="50" />
										<br />
										<p:commandButton icon="ui-icon-search" title="View" action="#{myCardsBean.selectAction(action)}" update=":actionForm" />

									</h:form>

								</p:dataList></td>

							</tr>

						</table>
					</td>
				</tr>
			</table>



	</ui:define>

</ui:composition>

</html>
